package com.dyna.demo.serial.controller;

import cn.hutool.core.util.StrUtil;
import com.dyna.core.exception.CustomException;
import com.dyna.demo.serial.service.DemoSerialServiceImpl;
import com.dyna.domain.resp.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Api("demo模块/demo/编号")
@RestController
@RequestMapping("/serial")
public class DemoSerialController {

    @Resource
    private DemoSerialServiceImpl demoSerialService;

    @ApiOperation("生成编号")
    @GetMapping("/create")
    public R<Boolean> create(@RequestParam("serialNumPre") String serialNumPre) {
        if (StrUtil.isBlank(serialNumPre)) {
            throw new CustomException("编号不能为空");
        }
        return R.isSuccess(demoSerialService.create(serialNumPre));
    }

}
